package com.toonly.defaultvalues;

import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.List;

public class Main {

    public static class Context {
        private Class<?> clazz;
        private Type type;

        public Context(Class<?> clazz, Type type) {
            this.clazz = clazz;
            this.type = type;
        }

        public Class<?> getClazz() {
            return clazz;
        }

        public void setClazz(Class<?> clazz) {
            this.clazz = clazz;
        }

        public Type getType() {
            return type;
        }

        public void setType(Type type) {
            this.type = type;
        }
    }

    private List<Integer> integerList;

    public static void main(String[] args) throws NoSuchFieldException {
        IntDefaultValueGenerator intDefaultValueGenerator = new IntDefaultValueGenerator();

        ListDefaultValueGenerator listDefaultValueGenerator = new ListDefaultValueGenerator();
        listDefaultValueGenerator.add(intDefaultValueGenerator);

        ChainedDefaultValueGenerator4Context root = new ChainedDefaultValueGenerator4Context();
        root.add(listDefaultValueGenerator);
        root.add(intDefaultValueGenerator);

        Field integerList = Main.class.getDeclaredField("integerList");
        root.set(new Context(integerList.getType(), integerList.getGenericType()));

        System.out.println(root.generate());
    }

}
